package org.teziyou.ticket.model;

import org.apache.log4j.Logger;

import org.teziyou.ticket.MemcachedUtil;
import org.teziyou.ticket.util.CacheKeyUtil;

import com.jfinal.plugin.activerecord.Model;

public class Member extends Model<Member> {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(Member.class);

	/**
	 * 
	 */
	private static final long serialVersionUID = 6102850149605520677L;
	
	public static Member dao = new Member();
	
	public Member getMemberById(long id) {
		logger.info("get dict from cache");
		String key = CacheKeyUtil.getMemberKey(id);
		Object obj = MemcachedUtil.client.get(key);
		if(obj==null) {
			logger.info("cache is null, get from db");
			obj = findById(id);
			MemcachedUtil.client.set(key, obj);
		}
		return (Member)obj;
	}

}
